<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let str = "hello";
    console.log(str.padStart(10, 'x')); // xxxxxhello
    console.log(str.padEnd(10, 'x'));  // helloxxxxx
    console.log(str.padStart(3, 'x')); // hello
    console.log(str.padEnd(3, 'x'));  // hello

    // 使用场景：对月份的填充
    let list = [];
    for (let i = 0; i < 13; i++) {
        list.push(i.toString().padStart(2, '0'))
    }
    console.log(list)
</script>
</body>
</html>
